package com.ruoyi.web.controller.admin;

import java.util.List;

import com.ruoyi.system.domain.dto.BdmAgentGiftPackageDto;
import com.ruoyi.system.service.IDistributionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.domain.BdmAgentGiftPackage;
import com.ruoyi.system.service.IBdmAgentGiftPackageService;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 代理礼包商品关联Controller
 */
@RestController
@RequestMapping("/admin/package")
public class BdmAgentGiftPackageController extends BaseController {

    @Autowired
    private IBdmAgentGiftPackageService bdmAgentGiftPackageService;

    /**
     * 查询代理礼包商品关联列表
     */
    @GetMapping("/list")
    public TableDataInfo list(BdmAgentGiftPackage bdmAgentGiftPackage) {
        startPage();
        List<BdmAgentGiftPackageDto> list = bdmAgentGiftPackageService.selectBdmAgentGiftPackageList(bdmAgentGiftPackage);
        return getDataTable(list);
    }

    /**
     * 新增代理礼包商品关联
     */
    @PostMapping
    public AjaxResult add(@RequestBody List<BdmAgentGiftPackage> bdmAgentGiftPackage) {
        return toAjax(bdmAgentGiftPackageService.insertBdmAgentGiftPackage(bdmAgentGiftPackage));
    }

    /**
     * 修改代理礼包商品关联
     */
    @PutMapping
    public AjaxResult edit(@RequestBody List<BdmAgentGiftPackage> bdmAgentGiftPackage) {
        return toAjax(bdmAgentGiftPackageService.updateBdmAgentGiftPackage(bdmAgentGiftPackage));
    }

    /**
     * 删除代理礼包商品关联
     */
    @DeleteMapping("/remove/{id}")
    public AjaxResult remove(@PathVariable Long id) {
        return toAjax(bdmAgentGiftPackageService.deleteBdmAgentGiftPackageById(id));
    }

    @Autowired
    private IDistributionService iDistributionService;

    @GetMapping("/ceshi")
    public AjaxResult list2() {
  //      iDistributionService.vipAward(174597L,"121212112",41L);
//        iDistributionService.agencyAward(2L,"121212112",51L);
//        iDistributionService.setLocation();
 //       iDistributionService.polymerizationPay("0.01","1072776957604659200");
        return success();
    }

}
